package com.sskj.wallet.presenter;

import com.lzy.okrx2.adapter.FlowableBody;
import com.sskj.common.base.HttpData;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.http.JsonConverter;
import com.sskj.wallet.bean.TransferRecordBean;
import com.sskj.wallet.ui.fragment.CoinRecordFragment;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.Flowable;
import okhttp3.Response;


public class CoinRecordFragmentPresenter extends BasePresenter<CoinRecordFragment> {

    public Flowable<List<TransferRecordBean>> getData(String address,String code, String type, String state, String p, String size) {
        return httpService.getTransferRecord(address,code, type, state, p, size)
                .converter(new JsonConverter<HttpData<PageBean<TransferRecordBean>>>() {
                })
                .adapt(new FlowableBody<>())
                .map(pageBeanHttpData -> pageBeanHttpData.getData().getList())
                .onErrorReturnItem(new ArrayList<>());
    }
}
